package edu.asu.sefcom.extract.profile;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;


public class ProfileCommDatesParser1 extends MultiFieldParser {

	Logger logger = Logger.getLogger(ProfileCommDatesParser1.class);

	@Override
	public List<String> extractFields(String post) {

		String created = "<b>Date created:.*</td>";
		String updated = "<b>Account type.*</i>";

		Pattern p = Pattern.compile(created);
		Matcher m = p.matcher(post);
		List<String> communities = new LinkedList<String>();
		String txt = m.find() ? m.group() : "";
		txt = Jsoup.parse(txt).text();
		List<String> l2 = Arrays.asList(txt.split(","));
		for (String st : l2) {
			communities.add(st);
		}
		p = Pattern.compile(updated);
		m = p.matcher(post);
		String upd = m.find() ? m.group() : "";
		upd = Jsoup.parse(upd).text();
		List<String> l1 = Arrays.asList(upd.split(","));
		for (String st : l1) {
			communities.add(st);
		}
		logger.warn(communities);
		return communities;
	}
}
